package cqueue.firing;

import java.util.Iterator;
import java.util.List;

import cqueue.EventListener;
import cqueue.ListenerEvent;

/**
 * LocalFireServiceStub performs event firing for a ListenerEventQueue.
 * This is accomplished by keeping a reference to the listeners.
 * 
 * NOTE: This may violate cohesion, perhaps there is some better way
 * to have the service know about the listeners.
 * 
 * 
 * @author Kristopher L. Kalish, James Madison University
 * @version 1 - March 29, 2008
 *
 */
public class LocalFireServiceStub implements FireService<ListenerEvent>
{
	private List<EventListener> listeners;
	
	public LocalFireServiceStub(List<EventListener> listeners)
	{
		System.out.println("Making local fire service...");
		this.listeners = listeners;
	}
	
	public void fire(ListenerEvent event)
	{
		for(EventListener listener : listeners)
		{
			System.out.println("Firing " + event + "."); //debug
			listener.handleEvent(event);
		}
	}
}
